<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <style>
        :root {
            --primary-color: #1890ff;
            --primary-hover: #40a9ff;
            --error-color: #f5222d;
            --text-color: rgba(0, 0, 0, 0.85);
            --border-color: #d9d9d9;
            --light-bg: #f5f5f5;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }

        body {
            background-color: var(--light-bg);
            color: var(--text-color);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .login-container {
            width: 100%;
            max-width: 400px;
            padding: 40px;
            background: white;
            border-radius: 8px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
        }

        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .login-header h1 {
            font-size: 24px;
            font-weight: 500;
            margin-bottom: 8px;
        }

        .login-header p {
            color: rgba(0, 0, 0, 0.45);
            font-size: 14px;
        }

        .login-form .form-group {
            margin-bottom: 24px;
        }

        .login-form label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            font-weight: 500;
        }

        .login-form input {
            width: 100%;
            padding: 12px 16px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 14px;
            transition: all 0.3s;
        }

        .login-form input:focus {
            outline: none;
            border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
        }

        .login-form .error-message {
            color: var(--error-color);
            font-size: 12px;
            margin-top: 4px;
            display: none;
        }

        .login-form input.invalid {
            border-color: var(--error-color);
        }

        .login-form input.invalid:focus {
            box-shadow: 0 0 0 2px rgba(245, 34, 45, 0.2);
        }

        .remember-forgot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 24px;
            font-size: 14px;
        }

        .remember-me {
            display: flex;
            align-items: center;
        }

        .remember-me input {
            margin-right: 8px;
        }

        .forgot-password a {
            color: var(--primary-color);
            text-decoration: none;
        }

        .login-btn {
            width: 100%;
            padding: 12px;
            background-color: var(--primary-color);
            border: none;
            border-radius: 4px;
            color: white;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .login-btn:hover {
            background-color: var(--primary-hover);
        }

        .login-footer {
            margin-top: 24px;
            text-align: center;
            font-size: 14px;
            color: rgba(0, 0, 0, 0.45);
        }

        .login-footer a {
            color: var(--primary-color);
            text-decoration: none;
            margin-left: 8px;
        }

        @media (max-width: 480px) {
            .login-container {
                padding: 30px 20px;
            }
        }
    </style>
</head>
<body>
<div class="login-container">
    <div class="login-header">
        <h1>欢迎登录</h1>
        <p>请输入您的账号和密码</p>
    </div>

    <form class="login-form" id="loginForm">
        <div class="form-group">
            <label for="username">用户名/邮箱</label>
            <input type="text" id="username" name="username" placeholder="请输入用户名或邮箱" required>
            <div class="error-message" id="username-error">请输入有效的用户名</div>
        </div>

        <div class="form-group">
            <label for="password">密码</label>
            <input type="password" id="password" name="password" placeholder="请输入密码" required minlength="6">
            <div class="error-message" id="password-error">密码长度至少6位</div>
        </div>

        <div class="remember-forgot">
            <div class="remember-me">
                <input type="checkbox" id="remember" name="remember">
                <label for="remember">记住我</label>
            </div>
            <div class="forgot-password">
                <a href="#">忘记密码?</a>
            </div>
        </div>

        <button type="submit" class="login-btn">登 录</button>
    </form>

    <div class="login-footer">
        还没有账号?<a href="#">立即注册</a>
    </div>
</div>

<script>
    // 表单验证逻辑
    const loginForm = document.getElementById('loginForm');
    const usernameInput = document.getElementById('username');
    const passwordInput = document.getElementById('password');
    const usernameError = document.getElementById('username-error');
    const passwordError = document.getElementById('password-error');

    loginForm.addEventListener('submit', function(e) {
        e.preventDefault();

        let isValid = true;

        // 验证用户名
        if (usernameInput.value.trim() === '') {
            usernameInput.classList.add('invalid');
            usernameError.style.display = 'block';
            isValid = false;
        } else {
            usernameInput.classList.remove('invalid');
            usernameError.style.display = 'none';
        }

        // 验证密码
        if (passwordInput.value.length < 6) {
            passwordInput.classList.add('invalid');
            passwordError.style.display = 'block';
            isValid = false;
        } else {
            passwordInput.classList.remove('invalid');
            passwordError.style.display = 'none';
        }

        if (isValid) {
            // 这里可以添加实际的登录逻辑
            console.log('登录提交:', {
                username: usernameInput.value,
                password: passwordInput.value,
                remember: document.getElementById('remember').checked
            });

            // 模拟登录成功跳转
            // window.location.href = '/dashboard';

            alert('登录成功!');
        }
    });

    // 输入时实时验证
    usernameInput.addEventListener('input', function() {
        if (this.value.trim() !== '') {
            this.classList.remove('invalid');
            usernameError.style.display = 'none';
        }
    });

    passwordInput.addEventListener('input', function() {
        if (this.value.length >= 6) {
            this.classList.remove('invalid');
            passwordError.style.display = 'none';
        }
    });
</script>
</body>
</html>>